package com.dq.domain.message.oneself;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.sys.section.SysSection;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author liuhui
 * @date 2019/11/20 0020 14:16:45
 */
@Data
@Entity
@ApiModel("消息")
public class Message extends BaseEntity implements VO.ToVO {

    /**
     * 通知/指令主题是添加时，设置
     * 采购主题根据门店名称自动生成；
     * 预约主题根据关联用户名自动生成
     */
    @ApiModelProperty("通知主题")
    @NotBlank
    public String theme;
    @ApiModelProperty("关联门店")
    @NotNull
    @ManyToOne
    public SysSection org;

    @ApiModelProperty("消息状态")
    @Enumerated(EnumType.ORDINAL)
    @NotNull
    protected MessageStatus messageStatus = MessageStatus.noSee;

    /**
     * 用户区分搜索
     */
    @ApiModelProperty("消息类型")
    @Enumerated(EnumType.ORDINAL)
    @NotNull
    protected MessageType messageType;

    public enum MessageStatus{
        noSee("未查看"),
        alreadySee("已查看");

        public String name;

        MessageStatus(String name){
            this.name = name;
        }
    }
    public enum MessageType{
        /**
         * 角标位置不可变
         */
        all("all"),
        subscribe("预约消息"),
        approval("审批消息"),
        notice("通知消息"),
        instruction("指令消息"),

        wxSystem("系统通知"),
        wxService("服务通知"),
        wxSubscribe("预约通知"),
        ;

        public String name;

        MessageType(String name){
            this.name = name;
        }
    }


    @Data
    @ApiModel(value = "视图")
    public static class Vo implements VO {

    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();

        return vo;
    }
}
